Subject: Re: BorderTop/BorderBottom etc..
From: [email-masked] (Oliver Seiler)
Date: 8 Jun 1994 23:54:59 -0700
Newsgroups: comp.sys.amiga.programmer

In article <[email-masked]>,
Terence Tan <[email-masked]> wrote:
>Quick questions:
>1. What is the best way to findout the inner width/height of a window
>   (Currently I use [Where pWdw is a struct Window  pointer]
>    pWdw->Width - pWdw->BorderLeft - pWdw->BorderRight or

This is because these fields measure different things. Generally if
you are subtracting and adding widths and border values you are going
to have to add or subtract a bit (to get it right the first time
try to figure out the offsets using an imaginary "small" window, with
maybe a one pixel wide border, in which case win->BorderLeft is 1,
a drawing area width of 0, etc... Then just scale up...)

>    pWdw->Height - pWdw->BorderTop - pWdw->BorderBottom). It doesn't
>    seem to do it properly cause I usually have to adjust it by 1 -2
>    pixels.

Use win->BorderTop, win->BorderLeft, etc. if you have the window's open. This
gives you the position of the first location *not* in the border. Before
opening, use the screen fields WBorLeft, WBorTop, etc (WBorTop doesn't
include the title bar, so add scr->Font->ta_YSize+1.) WBorRight and WBorBottom
may not be good to use if you aren't using the standard right and bottom
border settings...

To get the width and height of the non-border area of a window use
win->GZZWidth and win->GZZHeight. (Yes this works for non-GZZ windows - 
read the RKMs)

>2. Does pWdw->BorderTop take into account the drag bar at the top?
>   Is it font sensitive?

Yes to both. I usually just use win->BorderTop+INTERHEIGHT for all my gadgets,
etc..

If the window isn't open, use scr->WBorTop+scr->Font->ta_YSize+1 to get the
same value as win->BorderTop...

>3. Best way to clear a window?[BltClear??]

I'd avoid using the blitter for future compatibility reasons... Umm.
SetRast() followed by RefreshWindowFrame() would probably be fast. Even
better, avoid the RefreshWindowFrame() and use RectFill() on the window's
rastport (being sure to set the proper background color - best way of
getting this is using the DrawInfo pens array...)

-Oliver